﻿@using FormBuilder.Components.Drag
@using FormBuilder.Helpers
@inject ITranslationHelper translationHelper

<DraggableFormElement IsEditModeEnabled=@IsEditModeEnabled ParentContext="@ParentContext" Context="@Context" TDialog="FormPasswordDialog" TRecord="FormPasswordFieldRecord" Record="@Value">
    <Children>
        <div class="@ContainerClass">
            <RadzenLabel class="@LabelClass" Text="@translationHelper.Translate(Value, InputData, !IsEditModeEnabled)"></RadzenLabel>
            @if (Value.CanViewPassword)
            {
                <div class="@ViewPasswordContainerClass">
                    @if(isPasswordVisible)
                    {
                        <RadzenTextBox class="@PasswordClass" @bind-Value="@Value.Value"></RadzenTextBox>
                    }
                    else
                    {
                        <RadzenPassword class="@PasswordClass" @bind-Value="@Value.Value"></RadzenPassword>
                    }

                    <RadzenButton Variant="Variant.Outlined" ButtonStyle="ButtonStyle.Base" class="@ViewPasswordBtnClass" Click="TogglePasswordVisibility" Icon="@(isPasswordVisible ? "visibility_off" : "visibility")"></RadzenButton>
                </div>
            }
            else
            {
                <RadzenPassword class="@PasswordClass" @bind-Value="@Value.Value"></RadzenPassword>
            }
        </div>
     </Children>
</DraggableFormElement>